package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.LiangHaoItemBtn;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import org.come.entity.SellLiangHaoBase;
import org.come.entity.SellLianghaoAuc;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class AucJpanel extends JPanel implements MouseListener {
    private JTextField aucPrice;
    private LiangHaoItemBtn btnDoAuc,btnNoAuc;
    private SellLiangHaoBase liangHaoItem;

    private SellLianghaoAuc selllianghaoAuc;
    private JLabel lianghao;

    private boolean isReRuc = false;

    ImageIcon icon;
    public AucJpanel() throws Exception {
        this.setPreferredSize(new Dimension(532, 149));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);

        aucPrice = new JTextField();
        aucPrice.setBounds(30, 55, 290, 17);
        aucPrice.setOpaque(false);
        aucPrice.setBorder(BorderFactory.createEmptyBorder());
        aucPrice.setBackground(UIUtils.Color_BACK);
        aucPrice.setForeground(Color.WHITE);
        aucPrice.setCaretColor(Color.white);
        this.add(aucPrice);

        lianghao = new JLabel();
        lianghao.setBounds(30, 35, 500, 15);
        lianghao.setForeground(Color.WHITE);
        lianghao.setFont(new Font("宋体", 0, 14));
        this.add(lianghao);

        btnDoAuc = new LiangHaoItemBtn("inkImg/newbutton/B20.png", 1,this,3, "竞价");
        btnDoAuc.setBounds(88, 95, 59, 24);
        btnDoAuc.setFont(UIUtils.TXT_hyzjt16);
        btnDoAuc.setVerticalTextPosition(SwingConstants.CENTER);
        btnDoAuc.setHorizontalTextPosition(SwingConstants.CENTER);
        this.add(btnDoAuc);

        btnNoAuc = new LiangHaoItemBtn("inkImg/newbutton/B20.png", 1,this,10, "取消");
        btnNoAuc.setBounds(388, 95, 59, 24);
        btnNoAuc.setFont(UIUtils.TXT_hyzjt16);
        btnNoAuc.setVerticalTextPosition(SwingConstants.CENTER);
        btnNoAuc.setHorizontalTextPosition(SwingConstants.CENTER);
        this.add(btnNoAuc);
    }


    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (icon == null)
            icon = new ImageIcon("inkImg/newbackground/XJBK.png");
        if(!isReRuc && this.liangHaoItem!=null && this.liangHaoItem.getLianghao() !=null){
            lianghao.setText("当前竞拍靓号 " + this.liangHaoItem.getLianghao() + " , 剩余积分 " + RoleData.getRoleData().getLoginResult().getMoney().toString());
        }else if(isReRuc && this.selllianghaoAuc!=null && this.selllianghaoAuc.getLianghao() !=null){
            lianghao.setText("当前竞拍靓号 " + this.selllianghaoAuc.getLianghao() + " , 剩余积分 " + RoleData.getRoleData().getLoginResult().getMoney().toString());
        }
        g.drawImage(icon.getImage(), 0, 0, 532, 149, this);
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    public JTextField getAucPrice() {
        return aucPrice;
    }

    public void setAucPrice(JTextField aucPrice) {
        this.aucPrice = aucPrice;
    }

    public LiangHaoItemBtn getBtnDoAuc() {
        return btnDoAuc;
    }

    public void setBtnDoAuc(LiangHaoItemBtn btnDoAuc) {
        this.btnDoAuc = btnDoAuc;
    }

    public LiangHaoItemBtn getBtnNoAuc() {
        return btnNoAuc;
    }

    public void setBtnNoAuc(LiangHaoItemBtn btnNoAuc) {
        this.btnNoAuc = btnNoAuc;
    }

    public SellLiangHaoBase getLiangHaoItem() {
        return liangHaoItem;
    }

    public void setLiangHaoItem(SellLiangHaoBase liangHaoItem) {
        this.liangHaoItem = liangHaoItem;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public SellLianghaoAuc getSelllianghaoAuc() {
        return selllianghaoAuc;
    }

    public void setSelllianghaoAuc(SellLianghaoAuc selllianghaoAuc) {
        this.selllianghaoAuc = selllianghaoAuc;
    }

    public boolean isReRuc() {
        return isReRuc;
    }

    public void setReRuc(boolean reRuc) {
        isReRuc = reRuc;
    }
}
